package com.yj.web.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by yanlinyang on 2017/5/16.
 */
public class DateLongExchanger {
    public static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    public static long date2Stamp(String dateTime) throws ParseException {
        if (dateTime == null || dateTime.equals("")) return 0;
        Date date = simpleDateFormat.parse(dateTime);
        return date.getTime()/1000;
    }

    public static String stamp2Date(long seconds) {
        Date date = new Date(seconds * 1000);
        String formatedDate = simpleDateFormat.format(date);
        return formatedDate;
    }
}
